package com.opennetexam.manager;

import com.github.pagehelper.PageHelper;
import com.opennetexam.manager.config.MvcConfig;
import com.opennetexam.manager.config.ErrorPageConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.socket.config.annotation.EnableWebSocket;

import java.util.Properties;

/**
 * @author 奶茶
 */
@SpringBootApplication(exclude={
		RedisAutoConfiguration.class,
		RedisRepositoriesAutoConfiguration.class
})
@EnableCaching
@EnableTransactionManagement
@Import(value = {MvcConfig.class, ErrorPageConfig.class})
@EnableDiscoveryClient
@EnableAsync
@RestController
@EnableWebSocket
@EnableScheduling
public class ManagerApplication {
	@RequestMapping("/dnotdelet/mom.html")
	public String home() {
		return "helloworld!";
	}

	public static void main(String[] args) {
		ApplicationContext app = SpringApplication.run(ManagerApplication.class, args);
	}

	/**
	 * 配置mybatis分页插件
	 * @return
	 */
	@Bean
	public PageHelper pageHelper(){
		PageHelper pageHelper = new PageHelper();
		Properties properties = new Properties();
		properties.setProperty("offsetAsPageNum","true");
		properties.setProperty("rowBoundsWithCount","true");
		properties.setProperty("reasonable","true");
		properties.setProperty("dialect","mysql");
		pageHelper.setProperties(properties);
		return pageHelper;
	}
}
